<?php
session_start();
//Security check
if( $_SESSION['loggedIn'] == "yes" and
	$_SESSION['role'] == "organizer"){
	require("./databaseLogin.php");
	header("Location: ../chooseWedges.php");
	
	foreach($_POST['selectedWedges'] as $value)  {
		$query = "INSERT
				  INTO  `Game Wedges`(`Game ID`,`Wedge ID`)
				  VALUES ( ( SELECT `Game ID`
				             FROM   `Game`
				             WHERE  `Organizer ID` = '".$_SESSION['username']."' ),
				           '".mysql_real_escape_string($value)."');";
		$data		= mysql_query($query,$connection);
	} 

}
else{
	print "To perform this operation you must be logged in as an organizer!";
}
?>